//
//  FDAddManageView.m
//  FamousDoctorOnline
//
//  Created by 丁鼎 on 16/7/7.
//  Copyright © 2016年 wszyxc. All rights reserved.
//

#import "FDAddManageView.h"
#import "SVProgressHUD.h"

@interface FDAddManageView ()

@property (nonatomic,weak)UIView  *firstView;
@property (nonatomic,weak) UIView *secondView;
@property (nonatomic,weak) UIView *thirdView;
@property (nonatomic,weak) UIView *forthView;
@property (nonatomic,weak) UILabel *diseaseLabel;
@property (nonatomic,weak) UILabel *baseLabel;
@property (nonatomic,weak) UILabel *distrbuteLabel;
@property (nonatomic,weak) UILabel *photoLabel;

@end

@implementation FDAddManageView


-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self setupUI];
    }
    
    return self;
}

-(void)setupUI
{
    UIView *firstView = [[UIView alloc]init];
    firstView.backgroundColor = [UIColor whiteColor];
    self.firstView = firstView;
    [self addSubview:firstView];
    //添加tap手势
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickDiseaseButton)];
    
    tap1.numberOfTapsRequired = 1;
    
    tap1.numberOfTouchesRequired = 1;
    
    [self.firstView addGestureRecognizer:tap1];
    
    UIView *secondView = [[UIView alloc]init];
    secondView.backgroundColor = [UIColor whiteColor];
    self.secondView = secondView;
    [self addSubview:secondView];
    
    //添加tap手势
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickBaseButton)];
    
    tap2.numberOfTapsRequired = 1;
    
    tap2.numberOfTouchesRequired = 1;
    
    [self.secondView addGestureRecognizer:tap2];
    
    UIView *thirdView = [[UIView alloc]init];
    self.thirdView = thirdView;
    thirdView.backgroundColor = [UIColor whiteColor];
    [self addSubview:thirdView];
    
    UIView *forthView = [[UIView alloc]init];
    self.forthView = forthView;
    forthView.backgroundColor = [UIColor whiteColor];
    [self addSubview:forthView];
    
    
    UILabel *diseaseLabel = [[UILabel alloc]init];
    self.diseaseLabel = diseaseLabel;
    diseaseLabel.text = @"病症类型 :";
    [firstView addSubview:diseaseLabel];
    diseaseLabel.textColor = [UIColor blackColor];
   
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    self.diseaseButton  =button;
    [button addTarget:self action:@selector(clickDiseaseButton) forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundImage:[UIImage imageNamed:@"jt"] forState:UIControlStateNormal];
    [firstView addSubview:button];
    
    
    
    UILabel *diseaseNameLabel = [[UILabel alloc]init];
    self.diseaseNameLabel = diseaseNameLabel;
    diseaseNameLabel.text = @"请选择 :";
    diseaseNameLabel.textColor = [UIColor lightGrayColor];
    [firstView addSubview:diseaseNameLabel];
    
    
    UILabel *baseLabel = [[UILabel alloc]init];
    self.baseLabel = baseLabel;
    baseLabel.text = @"病症类型 :";
    [secondView addSubview:baseLabel];
    baseLabel.textColor = [UIColor blackColor];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.baseButton = button2;
    [button2 addTarget:self action:@selector(clickBaseButton) forControlEvents:UIControlEventTouchUpInside];
    [button2 setBackgroundImage:[UIImage imageNamed:@"jt"] forState:UIControlStateNormal];
    [secondView addSubview:button2];

    
    UILabel *baseNameLabel = [[UILabel alloc]init];
    self.baseNameLabel = baseNameLabel;
    baseNameLabel.text = @"请选择 :";
    baseNameLabel.textColor = [UIColor lightGrayColor];
    [secondView addSubview:baseNameLabel];
    
    UILabel *describeLabel = [UILabel new];
    self.distrbuteLabel = describeLabel;
    [thirdView addSubview:describeLabel];
    describeLabel.textColor = [UIColor blackColor];
    describeLabel.text = @"病症描述 :";
    
    
    UITextView *describeView = [UITextView new];
    self.distributeView = describeView;
    [thirdView addSubview:describeView];
    describeView.backgroundColor = FDColor(181, 181, 181);
    
    UILabel *photoLabel = [UILabel new];
    self.photoLabel = photoLabel;
    photoLabel.textColor = [UIColor blackColor];
    photoLabel.text = @"病例照片:";
    [forthView addSubview:photoLabel];
    
    
    UIButton *photoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.photo = photoBtn;
    [photoBtn addTarget:self action:@selector(clickPhotoBtn) forControlEvents:UIControlEventTouchUpInside];
    [forthView addSubview:photoBtn];
    [photoBtn setBackgroundImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateNormal];
   

}
-(void)layoutSubviews
{
    [self.firstView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(64);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(50);
        make.left.mas_equalTo(0);
    }];
    
    [self.secondView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.firstView.mas_bottom).offset(2);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(50);
        make.left.mas_equalTo(0);
    }];

    [self.thirdView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.secondView.mas_bottom).offset(10);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(250);
        make.left.mas_equalTo(0);
    }];
    
    [self.forthView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.thirdView.mas_bottom).offset(10);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(200);
        make.left.mas_equalTo(0);
    }];
    
    [self.diseaseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.firstView.mas_left).offset(10);
        make.top.mas_equalTo(15);
    }];

    [self.diseaseButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.firstView.mas_right).offset(-10);
        make.top.equalTo(self.diseaseLabel.mas_top);
        make.width.height.mas_equalTo(20);
    }];
    
    [self.diseaseNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.diseaseLabel.mas_top);
        make.right.equalTo(self.diseaseButton.mas_right).offset(-20);
    }];
    
    [self.baseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.secondView.mas_left).offset(10);
        make.top.mas_equalTo(15);
    }];
    
    [self.baseButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.secondView.mas_right).offset(-10);
        make.top.equalTo(self.baseLabel.mas_top);
        make.width.height.mas_equalTo(20);
    }];

    
    [self.baseButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.secondView.mas_right).offset(-10);
        make.top.equalTo(self.baseLabel.mas_top);
        make.width.height.mas_equalTo(20);
    }];
    
    [self.baseNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseLabel.mas_top);
        make.right.equalTo(self.baseButton.mas_right).offset(-20);
    }];

    [self.distrbuteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
    }];
    
    [self.distributeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.bottom.mas_equalTo(-10);
        make.top.equalTo(self.distrbuteLabel.mas_bottom).offset(5);
    }];
    
    [self.photoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(10);
    }];

    [self.photo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.equalTo(self.photoLabel.mas_bottom).offset(20);
        make.width.height.mas_equalTo(100);
    }];
}

-(void)clickDiseaseButton
{
    if(_tempBlock)		
    _tempBlock(0);
}

-(void)clickBaseButton
{
    if([self.diseaseNameLabel.text isEqualToString:@"请选择 :"])
    {
        [SVProgressHUD showErrorWithStatus:@"请先选择疾病选项"];
    }else{
        self.tempBlock(1);
    }
}

-(void)clickPhotoBtn
{
   if(_photoBlock)
   {
       _photoBlock();
   }
    
}

@end
